package user

import (
	"sanguo/codec/cs"
	"sanguo/node/node_game"

	"github.com/golang/protobuf/proto"
	//cs_msg "sanguo/protocol/cs/message"
)

var receiver *cs.Receiver

func SessionMsg(data []byte, user *User) {

	p, err := receiver.DirectUnpack(data)
	if err != nil {
		node_game.Infoln("SessoinMsg err:", err)
		return
	}
	req := p.(*cs.Message)

	roleModule := user.GetModuleByName("role")

	switch req.GetName() {
	case "*message.UpdateTeamToC":
		roleModule.(interface {
			UpdateTeamToC(proto.Message)
		}).UpdateTeamToC(req.GetData())
	default:
		return
	}

}

func init() {
	receiver = cs.NewReceiver("sc")
}
